<? 

require("required/dbconnect.php"); 
require_once("required/function.php");
$location_main="";
$title="Home";
require("required/header.php"); 

$latest_order=mysql_query("select * from os_bill_details where DATE_SUB(CURDATE(),INTERVAL 7 DAY)< create_date order by create_date desc,status desc")or die(mysql_error());


?>
<table width="100%"  cellpadding="0" cellspacing="5" height="500">
	
	<td width="84%" valign="top" >
		<table width="100%">
        	
			<tr>
            	<td class="title">Welcome, <?= strtoupper($_SESSION['admin_loginname']) ?></td>
			</tr>
              <?
				if(checkAccess("allow_statistic_view",0))
				{
					$get_total_order_under_verification=mysql_query("select count(*) as result from os_bill_details where status=1");
					$get_total_order_verified=mysql_query("select count(*) as result from os_bill_details where status=2");
					$get_total_order_waiting_payment_verification=mysql_query("select count(*) as result from os_bill_details where status=3");
					$get_total_order_payment_received=mysql_query("select count(*) as result from os_bill_details where status=4");
					$get_total_order_not_verified_paypal=mysql_query("select count(*) as result from os_bill_details where status=-3");
					$get_total_order_paid_by_paypal=mysql_query("select count(*) as result from os_bill_details where status=-4");
					$get_total_order_good_delivered=mysql_query("select count(*) as result from os_bill_details where status=5");
					$get_total_order_good_received=mysql_query("select count(*) as result from os_bill_details where status=6");
					$get_total_order_closed=mysql_query("select count(*) as result from os_bill_details where status=9");
				
			?>
			
        	<tr>
            	<td>
                	<table width="60%" class="solidborder">
                    	<Tr>
                        	<Td colspan="2" class="table_header" align="left">Order Report</Td>
                        </Tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td width="87%">Total orders under verification</td>
                        	<td width="13%"><a href="order_view.php?status=1"><?= mysql_result($get_total_order_under_verification,0,"result"); ?></a></td>
                      </tr>
                         <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total orders verified</td><td><a href="order_view.php?status=2"><?= mysql_result($get_total_order_verified,0,"result"); ?></a></td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total orders pending payment verification</td><td><a href="order_view.php?status=3"><?= mysql_result($get_total_order_waiting_payment_verification,0,"result"); ?></a></td>
                        </tr>
                         <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total orders paid by customers</td><td><a href="order_view.php?status=4"><?= mysql_result($get_total_order_payment_received,0,"result"); ?></a> </td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total orders not verified via PayPal</td><td><a href="order_view.php?status=-3"><?= mysql_result($get_total_order_not_verified_paypal,0,"result"); ?></a> </td>
                        </tr>
                         <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total verified by Paypal</td><td><a href="order_view.php?status=-4"><?= mysql_result($get_total_order_paid_by_paypal,0,"result"); ?></a> </td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total orders that have been delivered</td><td><a href="order_view.php?status=5"><?= mysql_result($get_total_order_good_delivered,0,"result"); ?></a></td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total orders received by customers</td><td><a href="order_view.php?status=6"><?= mysql_result($get_total_order_good_received,0,"result"); ?></a></td>
                        </tr>
                         <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total closed sales</td><td><a href="order_view.php?status=9"><?= mysql_result($get_total_order_closed,0,"result"); ?></a></td>
                        </tr>
                    </table>
                    <br /><br />
                </td>
            </tr>
             <?	
			 	if($module_redeemable==1)
				{
					$get_pending_redeem=mysql_query("select count(*) as result from os_bill_details where is_redeem='1' and status=0")or die(mysql_error());	
					$get_confirm_redeem=mysql_query("select count(*) as result from os_bill_details where is_redeem='1' and status=1")or die(mysql_error());
					$get_sent_redeem=mysql_query("select count(*) as result from os_bill_details where is_redeem='1' and status=2")or die(mysql_error());	
					$get_received_redeem=mysql_query("select count(*) as result from os_bill_details where is_redeem='1' and status=3")or die(mysql_error());		
				
			?>			
        	<tr>
            	<td>
                	<table width="60%" class="solidborder">
                    	<Tr>
                        	<Td colspan="2" class="table_header" align="left">Gift Redemption Report</Td>
                        </Tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td width="87%">Total pending redeem</td>
                        	<td width="13%"><a href="redeem_view_all.php?status=0"><?= mysql_result($get_pending_redeem,0,"result"); ?></a></td>
                      </tr>
                      <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total confirmed</td><td><a href="redeem_view_all.php?status=1"><?= mysql_result($get_confirm_redeem,0,"result"); ?></a></td>
                      </tr>
                      <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total sent</td><td><a href="redeem_view_all.php?status=2"><?= mysql_result($get_sent_redeem,0,"result"); ?></a></td>
                      </tr>
                      <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total received</td><td><a href="redeem_view_all.php?status=3"><?= mysql_result($get_received_redeem,0,"result"); ?></a></td>
                      </tr>
                        
                    </table>
                     <br /><br />
                </td>
            </tr>
              <?
				}
				$get_total_active_member=mysql_query("select count(*) as result from os_member where status='activated'")or die(mysql_error());	
				$get_total_inactive_member=mysql_query("select count(*) as result from os_member where status='inactivate'");		
			?>			
        	<tr>
            	<td>
                	<table width="60%" class="solidborder">
                    	<Tr>
                        	<Td colspan="2" class="table_header" align="left">Member Report</Td>
                        </Tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td width="87%">Total active members</td>
                        	<td width="13%"><a href="member_viewall.php?status=activated"><?= mysql_result($get_total_active_member,0,"result"); ?></a></td>
                      </tr>
                        <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total inactive member</td><td><a href="member_viewall.php?status=inactivate"><?= mysql_result($get_total_inactive_member,0,"result"); ?></a></td>
                        </tr>
                        
                    </table>
                     <br /><br />
                </td>
            </tr>    	 
			<?
			
				
					$month=date("m");
					$year=date("Y");
					$today=date("Y-m-d");
					$get_total_month=mysql_query("select sum(total_visit) as result from os_totalvisit where month(visit_date)=$month and year(visit_date)=$year");
					$get_total_overall=mysql_query("select sum(total_visit) as result from os_totalvisit");
					$get_total_today=mysql_query("select total_visit from os_totalvisit where visit_date='$today'");
					$get_total_main_cat=mysql_query("select count(*) as result from os_category");
					$get_total_sub_cat=mysql_query("select count(*) as result from os_sub_category");
					$get_total_active_product=mysql_query("select count(*) as result from os_products where status=1");
					$get_total_inactive_product=mysql_query("select count(*) as result from os_products where status=0");	
					
				
					
					if(mysql_num_rows($get_total_today)==0)
					{
						$total_visit_today=0;
					}else{
						$total_visit_today=mysql_result($get_total_today,0,"total_visit");
					}
			?>
			
        	<tr>
            	<td>
                	<table width="60%" class="solidborder">
                    	<Tr>
                        	<Td colspan="2" class="table_header" align="left">Visitor Report</Td>
                        </Tr>
                         <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td width="87%">Total visitor today</td><td width="13%"><a href="visitorstat.php"><?= $total_visit_today ?></a></td>
                        </tr>
                         <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total visitor current month</td><td><a href="visitorstat.php"><?= mysql_result($get_total_month,0,"result"); ?></a></td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total overall visitors</td><td><a href="visitorstat.php"><?= mysql_result($get_total_overall,0,"result"); ?></a></td>
                        </tr>
                         <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total product main category</td><td><a href="cat_management.php"><?= mysql_result($get_total_main_cat,0,"result"); ?></a> </td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total product sub category</td><td><a href="subcat_management.php"><?= mysql_result($get_total_sub_cat,0,"result"); ?></a></td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total active products</td><td><?= mysql_result($get_total_active_product,0,"result"); ?></td>
                        </tr>
                         <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total inactive products</td><td><?= mysql_result($get_total_inactive_product,0,"result"); ?></td>
                        </tr>
                    </table>
                    <br /><br />
                </td>
            </tr>    
            
            <tr>
            	<td>
                	<table width="60%" class="solidborder">
                    	<Tr>
                        	<Td colspan="2" class="table_header" align="left">Products Report</Td>
                        </Tr>
                        
                         <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td width="87%">Total product main category</td>
                        	<td width="13%"><a href="cat_management.php"><?= mysql_result($get_total_main_cat,0,"result"); ?></a> </td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total product sub category</td><td><a href="subcat_management.php"><?= mysql_result($get_total_sub_cat,0,"result"); ?></a></td>
                        </tr>
                        <tr height="20" valign="top" class="table_item_odd" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_odd'">
                        	<td>Total active products</td><td><?= mysql_result($get_total_active_product,0,"result"); ?></td>
                        </tr>
                         <tr height="20" valign="top" class="table_item_even" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='table_item_even'">
                        	<td>Total inactive products</td><td><?= mysql_result($get_total_inactive_product,0,"result"); ?></td>
                        </tr>
                    </table>
                    <br /><br />
                </td>
            </tr>    
          
          
		
        <? } ?>
        </table>
		</td>
	</table>
<? require("required/footer.php"); ?>